﻿@model UserChangePasswordSharedDto
@Html.Extra()
@{
    Layout = "~/Views/Shared/OA/_Edit.cshtml";
}
@section Toolbar
{
    @Html.MyNet().Button(new ButtonOptions { Text = "保存", Click = "save" })
    @if (Request["From"]!="LoginView")
    {
        @Html.MyNet().Button(new ButtonOptions { Text = "返回", Click = "back" })
    }
}
@section Main
{
    @Html.HiddenFor(model => model.Id)
    <table>
        <tr>
            <th>
                @Html.LabelFor(model => model.OldPassword, "旧密码")
            </th>
            <td>
                @Html.MyNet().PasswordFor(model => model.OldPassword, new ValidateOptions
                {
                    RequiredError = "请输入旧密码"
                })
                @Html.MyNet().ValidationMessageFor(model => model.OldPassword)
            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.NewPassword, "新密码")
            </th>
            <td>
                @Html.MyNet().PasswordFor(model => model.NewPassword, new ValidateOptions
                {
                    RequiredError = "请输入新密码",
                    LengthError = "请输入6-20个字符",
                    LengthMin = 6,
                    LengthMax = 20,
                })
                @Html.MyNet().ValidationMessageFor(model => model.NewPassword)
            </td>
        </tr>
    </table>
}
<script>

    function save()
    {
        var form = $("form");
        if (!form.valid()) return;

        $.ajax
        ({
            url: form.attr("action"),
            data: form.serialize(),
            type: "post",
            error: disposeError,
            success: function (result)
            {
                if (disposeException(result)) return;
                back(true, null, "修改成功！");
            }
        });
    }

</script>
